//
//  XyViewController.m
//  day1
//
//  Created by 于跃隆 on 2020/4/5.
//  Copyright © 2020 于跃隆. All rights reserved.
//

#import "XyViewController.h"

@interface XyViewController ()



//导航渐变view
@property (nonatomic ,strong) UIView *Jbview;



@end

@implementation XyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setNavUiCtion];
    
//    WebVC *vc = [[WebVC alloc] init];
//    vc.navTitle=@"用户协议";
//    [vc loadFromURLStr:@"http://jzh5.3nn1.com/#/protocol"];
    
    [self loadFromURLStr:@"http://jzh5.3nn1.com/#/protocol"];
    self.hidesBottomBarWhenPushed = YES;
//    [self.webView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.mas_equalTo(_Jbview.bottom).mas_equalTo(KSCHEIGHT(100));
//        make.left.right.bottom.mas_equalTo(self.view);
//        
//    }];
    
//    //协议文字
//    UILabel *xieYLabel = [[UILabel alloc] init];
//    xieYLabel.text = @"服务协议服务协议服务协议服务协议服务协议服务协议服务协议服务协议服务协议服务协议服务协议服务协议服务协议服务协议服务协议服务协议服务协议服务协议服务协议服务协议服务协议服务协议";
//    xieYLabel.textColor = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
//    xieYLabel.font = kFONT(15);
//    xieYLabel.lineBreakMode = NSLineBreakByWordWrapping;
//    xieYLabel.numberOfLines =  10;
//    xieYLabel.textAlignment = NSTextAlignmentLeft;
////    [self.view addSubview:xieYLabel];
//
//
//
//
//    //添加滚动视图
//    UIScrollView *scrView = [[UIScrollView alloc] init];
//    scrView.scrollEnabled = YES;
////    scrView.pagingEnabled = YES;
//    scrView.contentSize = CGSizeMake(0, KSCHEIGHT(self.view.frame.size.height-95));
//
//    [scrView addSubview:xieYLabel];
//    [self.view addSubview:scrView];
//
//
//    //设置label约束
//    [scrView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.mas_equalTo(_Jbview.mas_bottom).mas_equalTo(KSCHEIGHT(10));
//        make.left.mas_equalTo(self.view.mas_left).mas_equalTo(kSCRATIO(25));
//        make.right.mas_equalTo(self.view.mas_right).mas_equalTo(kSCRATIO(-25));
//        make.bottom.mas_equalTo(self.view.mas_bottom).mas_equalTo(KSCHEIGHT(0));
//    }];
//    //设置scroll约束
//    [xieYLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.mas_equalTo(KSCHEIGHT(0));
//        make.left.mas_equalTo(kSCRATIO(0));
//        make.right.mas_equalTo(kSCRATIO(0));
//        make.bottom.mas_equalTo(KSCHEIGHT(0));
////        make.width.mas_equalTo(scrView);
////        make.height.mas_equalTo(scrView);
//    }];
    
    
    
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [[UIApplication sharedApplication] setStatusBarHidden:NO];
    self.navigationController.navigationBar.hidden = NO;
}
-(void)viewDidDisappear:(BOOL)animated{
    [super viewDidDisappear:animated];
    [[UIApplication sharedApplication] setStatusBarHidden:NO];
    self.Jbview.hidden = YES;
    self.navigationController.navigationBar.hidden = NO;
}

-(void)setNavUiCtion{
    //245 246 251
        self.view.backgroundColor = [UIColor colorWithRed:245/255.0 green:246/255.0 blue:251/255.0 alpha:1.0];
        //设置导航条颜色
            _Jbview = [[UIView alloc] init];
            _Jbview.userInteractionEnabled = YES;
        //    Jbview.frame = CGRectMake(0,KSCHEIGHT(-37),kSCRATIO(self.view.frame.size.width),KSCHEIGHT(75));

            CAGradientLayer *gl = [CAGradientLayer layer];
            gl.frame = CGRectMake(0,KSCHEIGHT(0),kSCRATIO(self.view.frame.size.width),KSCHEIGHT(85));
            gl.startPoint = CGPointMake(0, 0);
            gl.endPoint = CGPointMake(1, 1);
            gl.colors = @[(__bridge id)[UIColor colorWithRed:247/255.0 green:65/255.0 blue:91/255.0 alpha:1.0].CGColor,(__bridge id)[UIColor colorWithRed:251/255.0 green:171/255.0 blue:102/255.0 alpha:1.0].CGColor];
            gl.locations = @[@(0.0),@(1.0)];
            [_Jbview.layer addSublayer:gl];
            
            [self.navigationController.navigationBar addSubview:_Jbview];
//        [self.view addSubview:_Jbview];
            
            //返回button
            UIButton *backBtn = [[UIButton alloc] init];
            [backBtn setBackgroundImage:[UIImage imageNamed:@"backButton"] forState:UIControlStateNormal];
            [backBtn addTarget:self action:@selector(BackClick) forControlEvents:UIControlEventTouchUpInside];
            [_Jbview addSubview:backBtn];
            
            //标题文字
            UILabel *navtitle = [[UILabel alloc] init];
            navtitle.text = @"服务协议";
            navtitle.textColor = [UIColor whiteColor];
            navtitle.font = kFONT(18);
            [_Jbview addSubview:navtitle];
            
            [_Jbview mas_makeConstraints:^(MASConstraintMaker *make) {
                make.top.mas_equalTo(KSCHEIGHT(-37));
                make.width.mas_equalTo(kSCRATIO(self.view.frame.size.width));
                make.height.mas_equalTo(KSCHEIGHT(85));
            }];
            [backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.mas_equalTo(_Jbview.mas_left).mas_equalTo(kSCRATIO(20));
                make.bottom.mas_equalTo(_Jbview.bottom).mas_equalTo(KSCHEIGHT(-15));
                make.width.mas_equalTo(kSCRATIO(10));
                make.height.mas_equalTo(KSCHEIGHT(18));
            }];
            [navtitle mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerX.mas_equalTo(_Jbview);
                make.bottom.mas_equalTo(_Jbview.bottom).mas_equalTo(KSCHEIGHT(-15));
                
            }];
}
- (void)BackClick{
//    [[AppDelegate shareAppDelegate ] setLoginViewController];
    [self.navigationController popViewControllerAnimated:NO];
//    UIViewController *viewController = self;
//        if (viewController) {
//            [viewController dismissViewControllerAnimated:NO completion:nil];
//        }
}


@end
